package org.tangolyricstagger.gui;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;

public class AboutDialog extends Dialog {

	/**
	 * Create the dialog.
	 * 
	 * @param parentShell
	 */
	public AboutDialog(Shell parentShell) {
		super(parentShell);
	}

	/**
	 * Create contents of the dialog.
	 * 
	 * @param parent
	 */
	@Override
	protected Control createDialogArea(Composite parent) {
		getShell().setText("About");
		Composite container = (Composite) super.createDialogArea(parent);
//		GridLayout gridLayout = (GridLayout) container.getLayout();

		Label label;
		Link link;
		label = new Label(container, SWT.NONE);
		label.setText("When you're running this program, it will download the lyrics from ");
		link = new Link(container, SWT.NONE);
		link.setText("<a>www.todotango.com</a>");
		label = new Label(container, SWT.NONE);
		label.setText("A big thank goes to Todotango for the friendly permission.");
		label = new Label(container, SWT.NONE);
		label.setText("\nThis software is developed and maintained by Jörg Mattes.\nCheck the project home for news: ");
		link = new Link(container, SWT.NONE);
		link.setText("<a>code.google.com/p/tangolyricstagger</a>");
		label = new Label(container, SWT.NONE);
		label.setText("If you like this software, I'd be happy if you like ");
		link = new Link(container, SWT.NONE);
		link.setText("<a>www.facebook.com/TangoLyricsTagger</a>");
		label = new Label(container, SWT.NONE);
		label.setText("PS: At the moment, clicking the links doesn't work, I'll try to find out why.");

		// link.addSelectionListener(new SelectionAdapter() {
		// @Override
		// public void widgetSelected(SelectionEvent e) {
		// System.out.println("You have selected: " + e.text);
		// try { // Open default external browser
		// // PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL("http://www.todotango.com"));
		// } catch (Exception ex) {
		// log.error("Can't open link to todotango", ex);
		// }
		// }
		// });
		return container;
	}

	/**
	 * Create contents of the button bar.
	 * 
	 * @param parent
	 */
	@Override
	protected void createButtonsForButtonBar(Composite parent) {
		createButton(parent, IDialogConstants.OK_ID, "Wow!", true);
	}

	/**
	 * Return the initial size of the dialog.
	 */
	@Override
	protected Point getInitialSize() {
		return new Point(552, 300);
	}
}
